package com.itheima.udp3;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class ReceiveClient {

    public static void main(String[] args) throws IOException {

        //创建对象
        DatagramSocket ds = new DatagramSocket(10010);
        //接受数据
        byte[] bytes = new byte[64*1024];
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length);
        while (true) {
            ds.receive(dp);
            //展示数据
            int length = dp.getLength();
            String s = new String(bytes, 0, length);
            System.out.println(s);
        }
        // 释放资源
      //  ds.close();


    }
}
